///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
#include <Scene/Culling/AABBox.h>
#include <Math/Vec3f.h>

//-----------------------------------------------------------------------------

AABBox::AABBox( const Vec3f &corner,  f32 x, f32 y, f32 z)
{
	setBox(corner,x,y,z);
}

//-----------------------------------------------------------------------------

AABBox::AABBox(void)
{
	corner.x = 0; corner.y = 0; corner.z = 0;

	x = 1.0f;
	y = 1.0f;
	z = 1.0f;
}

//-----------------------------------------------------------------------------

AABBox::~AABBox()
{
}

//-----------------------------------------------------------------------------

void AABBox::setBox( const Vec3f &corner,  f32 x, f32 y, f32 z)
{
	this->corner = corner;

	if (x < 0.0) {
		x = -x;
		this->corner.x -= x;
	}
	if (y < 0.0) {
		y = -y;
		this->corner.y -= y;
	}
	if (z < 0.0) {
		z = -z;
		this->corner.z -= z;
	}
	this->x = x;
	this->y = y;
	this->z = z;
}

//-----------------------------------------------------------------------------

Vec3f AABBox::getVertexP(const Vec3f &normal)
{
	Vec3f res = corner;

	if (normal.x > 0)
		res.x += x;

	if (normal.y > 0)
		res.y += y;

	if (normal.z > 0)
		res.z += z;

	return(res);
}

//-----------------------------------------------------------------------------

Vec3f AABBox::getVertexN(const Vec3f &normal)
{
	Vec3f res = corner;

	if (normal.x < 0)
		res.x += x;

	if (normal.y < 0)
		res.y += y;

	if (normal.z < 0)
		res.z += z;

	return(res);
}

//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
